package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhAdminPic;
import com.ruoyi.xh.service.IXhAdminPicService;

/**
 * 图库Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "图库Controller",value = "图库Controller")
@RestController
@RequestMapping("/xh/adminPic")
public class XhAdminPicController extends BaseController {

    @Autowired
    private IXhAdminPicService xhAdminPicService;

    /**
     * 查询图库列表
     */
    @PreAuthorize("@ss.hasPermi('xh:adminPic:list')")
    @GetMapping("/list")
    @ApiOperation("查询图库列表")
    public TablePageDataInfo<XhAdminPic> list(XhAdminPic xhAdminPic) {
        return TablePageDataInfo.success(xhAdminPicService.selectXhAdminPicList(xhAdminPic));
    }

    /**
     * 获取图库详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:adminPic:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取图库详细信息")
    public CommentResult<XhAdminPic> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhAdminPicService.selectXhAdminPicById(id));
    }

    /**
     * 新增图库
     */
    @PreAuthorize("@ss.hasPermi('xh:adminPic:add')")
    @Log(title = "图库", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增图库")
    public CommentResult<XhAdminPic> add(@RequestBody XhAdminPic xhAdminPic) {
            xhAdminPicService.insertXhAdminPic(xhAdminPic);
        return CommentResult.success();
    }

    /**
     * 修改图库
     */
    @PreAuthorize("@ss.hasPermi('xh:adminPic:edit')")
    @Log(title = "图库", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改图库")
    public CommentResult<XhAdminPic> edit(@RequestBody XhAdminPic xhAdminPic) {
            xhAdminPicService.updateXhAdminPic(xhAdminPic);
        return CommentResult.success();
    }

    /**
     * 删除图库
     */
    @PreAuthorize("@ss.hasPermi('xh:adminPic:remove')")
    @Log(title = "图库", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除图库")
    public CommentResult<XhAdminPic> remove(@PathVariable Long[] ids) {
            xhAdminPicService.deleteXhAdminPicByIds(ids);
        return CommentResult.success();
    }
}
